home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / P_ROBO31.ZIP / PATROL.PR < prev    next >
Text File  |  1989-10-23  |  2KB  |  89 lines

  1. (**************************************************************************)
  2. (*                             W A R N I N G                              *)
  3. (*                                                                        *)
  4. (*  This Robot has NOT been designed to take advantage of the advanced    *)
  5. (*  features of P-ROBOTS, such as, Shields, Fuel, Teams or Obstructions.  *)
  6. (**************************************************************************)
  7.  
  8. {
  9.   The Southern Patrol
  10.  
  11.  
  12.   Based on a C-Robot by Dave Chess
  13.  
  14.   Strategy: run to the south border, and then run back and forth
  15.      along it, firing at anything that comes into range.
  16.  
  17. }
  18.   PROCEDURE Patrol;
  19.  
  20.   VAR
  21.     course, scandir, Range : Integer;
  22.  
  23.  
  24.     PROCEDURE TURN;
  25.     BEGIN
  26.       { Time to turn? }
  27.       IF ((loc_x < 200) AND (course = 180)) THEN drive(course, 0); {I.E.,Stop}
  28.       IF ((loc_x > 800) AND (course = 0)) THEN drive(course, 0); {I.E.,Stop}
  29.       { Hit anything? }
  30.       IF (speed = 0) THEN
  31.         BEGIN
  32.           course := 180-course;
  33.           drive(course, 100);
  34.         END;
  35.     END; {Turn}
  36.  
  37.  
  38.   BEGIN {Main Patrol}
  39.  
  40.     { Go south, young 'droid! }
  41.     WHILE (loc_y > 5) DO
  42.       BEGIN
  43.         drive(270, 100);
  44.         WHILE (speed > 0) DO cannon(Random(359), 200);
  45.       END;
  46.  
  47.     { Set up for patrol }
  48.     IF (Random(1) = 0)
  49.     THEN course := 0
  50.     ELSE course := 180;
  51.  
  52.     { Patrol forever }
  53.     REPEAT
  54.       { Time to turn? } TURN;
  55.       { Look in various directions }
  56.       Range := scan(4, 4);
  57.       WHILE ((Range > 0) AND (Range < 700)) DO
  58.         BEGIN
  59.           cannon(0, Range);
  60.           Range := scan(4, 4);
  61.           { Time to turn? } TURN;
  62.         END;
  63.       Range := scan(176, 4);
  64.       WHILE ((Range > 0) AND (Range < 700)) DO
  65.         BEGIN
  66.           cannon(180, Range);
  67.           Range := scan(176, 4);
  68.           { Time to turn? } TURN;
  69.         END;
  70.       Range := scan(90, 10);
  71.       WHILE ((Range > 0) AND (Range < 700)) DO
  72.         BEGIN
  73.           cannon(85+Random(10), Range);
  74.           Range := scan(90, 10);
  75.           { Time to turn? } TURN;
  76.         END;
  77.       scandir := Random(160)+10;
  78.       Range := scan(scandir, 10);
  79.       WHILE ((Range > 0) AND (Range < 700)) DO
  80.         BEGIN
  81.           cannon(scandir+Random(10)-5, Range);
  82.           Range := scan(scandir, 10);
  83.           { Time to turn? } TURN;
  84.         END;
  85.  
  86.     UNTIL Dead OR Winner; {REPEAT patrol-forever }
  87.   END; { End Patrol Main }
  88.  
  89.